package com.leilei.greendao.mode;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import com.leilei.greendao.greendao.DaoSession;
import com.leilei.greendao.greendao.PersonDao;
import com.leilei.greendao.greendao.SonDao;

/**
 * Created by leilei on 2018/2/2.
 */
@Entity
public class Son {
    @Id(autoincrement = true)
    private Long son_id;
    private String age;
    private String titile;
    private Long scorid;
    @ToOne(joinProperty = "scorid")
    private Person person;
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /** Used for active entity operations. */
    @Generated(hash = 1926509084)
    private transient SonDao myDao;
    @Generated(hash = 2079577852)
    public Son(Long son_id, String age, String titile, Long scorid) {
        this.son_id = son_id;
        this.age = age;
        this.titile = titile;
        this.scorid = scorid;
    }
    @Generated(hash = 1259336981)
    public Son() {
    }
    public Long getSon_id() {
        return this.son_id;
    }
    public void setSon_id(Long son_id) {
        this.son_id = son_id;
    }
    public String getAge() {
        return this.age;
    }
    public void setAge(String age) {
        this.age = age;
    }
    public Long getScorid() {
        return this.scorid;
    }
    public void setScorid(Long scorid) {
        this.scorid = scorid;
    }
    @Generated(hash = 1154009267)
    private transient Long person__resolvedKey;
    /** To-one relationship, resolved on first access. */
    @Generated(hash = 103677970)
    public Person getPerson() {
        Long __key = this.scorid;
        if (person__resolvedKey == null || !person__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            PersonDao targetDao = daoSession.getPersonDao();
            Person personNew = targetDao.load(__key);
            synchronized (this) {
                person = personNew;
                person__resolvedKey = __key;
            }
        }
        return person;
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 9886567)
    public void setPerson(Person person) {
        synchronized (this) {
            this.person = person;
            scorid = person == null ? null : person.getId();
            person__resolvedKey = scorid;
        }
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 838735897)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getSonDao() : null;
    }
    public String getTitile() {
        return this.titile;
    }
    public void setTitile(String titile) {
        this.titile = titile;
    }
}
